package l.l.w.CodingInterviews;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by llw on 2018/4/25/0025.
 */
public class 二进制串能否被3整除 {

    public boolean isDivide(String str){
        System.out.println(str);
        Pattern p = Pattern.compile("0*(1((01*0)|(10*1))*10*)*");
        Matcher matcher = p.matcher(str);
        System.out.println(matcher.matches());
        return matcher.matches();
    }

    public static void main(String[] args) {
        int integer = 1230621;
        new 二进制串能否被3整除().isDivide(Integer.toBinaryString(integer));
    }
}
